let isusername = false;
let ispassword = false;
let ipts = document.querySelectorAll('input');
let btn = document.querySelector('button');
ipts[0].onblur = function () {
  let reg = /^1[345789]\d{9}$/;
  if (reg.test(this.value)) {
    isusername = true;
  } else {
    isusername = false;
  }
};
ipts[1].onblur = function () {
  let reg = /^.{6,16}$/;
  if (reg.test(this.value)) {
    ispassword = true;
  } else {
    ispassword = false
  }
};
btn.onclick = function () {
  if (isusername && ispassword) {
    let username = ipts[0].value;
    let password = ipts[1].value;
    axios.get(loginAPI, {
        params: {
          username,
          password
        },
      })
      .then((res) => {
        let {
          data
        } = res;
        console.log(data);
        localStorage.setItem('uid', data.data.id);
        localStorage.setItem('username', data.data.username);
        localStorage.setItem('token', data.data.token);
        alert(data.msg);
        if (data.code == 1) {
          // console.log(123)
          location.href = "../index.html"
          /*  data:
             appid: ""
           id: "64150"
           identity: "0"
           is_delete: "0"
           password: "000000"
           status: "0"
           token: "ce57259e797c5deb2055c8d3202b533b"
           username: "13246579871" */
        }
      });
  };
};